<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <span><router-link to="/login">登录</router-link></span>
    <span><router-link to="/register">注册</router-link></span>
    <hr>
    <router-view></router-view>
</div>
</body>
<script src="../node_modules/vue/dist/vue.js"></script>
<!--引入vue-router时一定要在vue的下面-->
<script src="../node_modules/vue-router/dist/vue-router.js"></script>
<script src="js/login.js"></script>
<script src="js/register.js"></script>
<script>
    const router = new VueRouter({
        routes: [
            {
                path: "/login", //路由路径，必须以"/"开头
                component: loginForm //路径对应的组件
            },
            {
                path: "/register",
                component: registerForm
            }
        ]
    })

    const app = new Vue({
        el: "#app",
        //注册子组件，如果引入了路由这里就不需要引入了
        // components: {
        //     loginForm,
        //     registerForm
        // },
        //引入路由，让路由与组件产生关联
        router
    })
</script>
</html>